/*
 * Copyright (c) 2012-2014, EpicSaaS Yuan Xin technology Co., Ltd.
 * 
 * All rights reserved.
 */
package com.epicsaas.app.ksdapp.controller.phone;

import com.epicpaas.sdk.core.api.logging.Logger;
import com.epicpaas.sdk.core.api.logging.LoggerFactory;
import com.epicpaas.sdk.core.api.ServiceResult;
import com.epicsaas.framework.util.DateTimeUtils;
import com.epicsaas.app.ksdapp.common.MVCViewName;
import com.epicsaas.app.ksdapp.android.bean.BrandRecommend;
import com.epicsaas.app.ksdapp.android.bean.PageEntity;
import com.epicsaas.app.ksdapp.android.bean.Product;
import com.epicsaas.app.ksdapp.appobject.ShopUserAO;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;

import javax.validation.Valid;

import org.springframework.ui.Model;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Product控制器。商品处理
 * 
 */
@Controller
@RequestMapping(value = "/phone/brand")
public class BrandController {

    private static Logger LOG = LoggerFactory.getLogger(BrandController.class);

    @RequestMapping(value = "", method = RequestMethod.GET)
    @ResponseBody
    public Object getAll(Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());
        ServiceResult<Object> ret = new ServiceResult<Object>();
        ret.setData(DateTimeUtils.formateDateToStr(new Date(), DateTimeUtils.FORMAT_YMD_HMS));
        return ret;
    }

    @RequestMapping(value = "/add", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object add(Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());
        ServiceResult<Object> ret = new ServiceResult<Object>();
        ret.setData(DateTimeUtils.formateDateToStr(new Date(), DateTimeUtils.FORMAT_YMD_HMS));
        return ret;
    }

    /**
     * 
     * @param type   //商品类型   
     * @param pageNumber //第几页
     * @param pageSize //每页大小
     * @param orderProperty  //排序字段
     * @param orderDirection   //asc desc
     * @param model
     * @param request
     * @return
     */
    @RequestMapping(value = "/list", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object list(String type, int pageNumber, int pageSize, String orderProperty, String orderDirection,
            Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());
        //type 特卖
        List<BrandRecommend> listEntity = new ArrayList<BrandRecommend>();
        BrandRecommend brandRecommend = new BrandRecommend();
        brandRecommend.setId(1);
        brandRecommend
                .setAppImage("http://221.178.139.194:13780/upload/image/201501/40345d35-97e6-421f-8030-5cbb611ef8d2.png");
        brandRecommend.setName("cscs");
        brandRecommend
                .setLogo("http://221.178.139.194:13780/upload/image/201502/42cb10e2-3c26-45e7-bea7-fad36a881b84.jpg");

        brandRecommend
                .setImage("http://221.178.139.194:13780/upload/image/201502/10380e1c-8e47-4eac-ada2-366728eb1ad8.png");

        return listEntity;
    }

    @RequestMapping(value = "/view/{dataId}", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object viewById(@PathVariable String dataId, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());
        ServiceResult<Object> ret = new ServiceResult<Object>();
        ret.setData(DateTimeUtils.formateDateToStr(new Date(), DateTimeUtils.FORMAT_YMD_HMS));
        return ret;
    }

    @RequestMapping(value = "/update/{dataId}", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object updateById(@PathVariable String dataId, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());
        ServiceResult<Object> ret = new ServiceResult<Object>();
        ret.setData(DateTimeUtils.formateDateToStr(new Date(), DateTimeUtils.FORMAT_YMD_HMS));
        return ret;
    }

    @RequestMapping(value = "/delete/{dataId}", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Object deleteById(@PathVariable String dataId, Model model, HttpServletRequest request) {
        LOG.info("有访问来自，IP: %s USER-AGENT: %s", request.getRemoteAddr(), request.getHeader("user-agent"));
        LOG.info("SessionId %s", request.getSession().getId());
        ServiceResult<Object> ret = new ServiceResult<Object>();
        ret.setData(DateTimeUtils.formateDateToStr(new Date(), DateTimeUtils.FORMAT_YMD_HMS));
        return ret;
    }

}
